import { getShowString } from "../utils/mirUtil";

export function Main(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    let g0 = GameLib.GetGVar(0)
    let hour = new Date().getHours();
    if (g0 <= 1 && hour < 19) {
        Player.MessageBox("请等待19点开区")
        return;
    }

    const S = `欢迎光临!你可以在我这里享受以下服务.\\
请选择你要前往的地区:\\
┏━━━━┳━━━━┳━━━━┳━━━━┓\\
┃<免费传送/@传送.city>┃<金币传送/@传送.金币传送>┃<元宝传送/@传送.元宝传送查看>┃<查看时间/@传送.showTime>┃\\
┗━━━━┻━━━━┻━━━━┻━━━━┛\\
`
    Npc.Say(Player, S)
}

export function city(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    let showNameList = [
        {
            name: '比齐大城',
            fucName: '传送.citymove(0,333,268,0)'
        },
        {
            name: '盟重土城',
            fucName: '传送.citymove(3,330,330,0)'
        },
        {
            name: '封魔神谷',
            fucName: '传送.citymove(4,240,200,0)'
        },
        {
            name: '白 日 门',
            fucName: '传送.citymove(11,180,325,0)'
        },
        {
            name: '比齐矿区',
            fucName: '传送.citymove(0,663,215,0)'
        },
        {
            name: '封魔矿区',
            fucName: '传送.citymove(4,138,69,0)'
        },
        {
            name: '蜈蚣洞穴',
            fucName: '传送.citymove(3,142,93,0)'
        },
        {
            name: '牛魔一层',
            fucName: '传送.citymove(D2071,224,220,0)'
        },
        {
            name: '尸 魔 洞',
            fucName: '传送.citymove(5,526,612,0)'
        },
        {
            name: '骨 魔 洞',
            fucName: '传送.citymove(5,548,128,0)'
        },
        {
            name: '骨 魔 洞',
            fucName: '传送.citymove(5,548,128,0)'
        },
        {
            name: '幻境一层',
            fucName: '传送.citymove(H001, 73, 67,0)'
        },
    ]

    let ItemsString = getShowString(showNameList);
    Npc.Say(Player, ItemsString)

}

export function 金币传送(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    let showNameList = [
        {
            name: '沃玛三层',
            fucName: '传送.citymove(D023,50,364,50000)',
            hint: "5w",
        },
        {
            name: '猪洞七层',
            fucName: '传送.citymove(D716,24,27,50000)',
            hint: "5w",
        },
        {
            name: '祖玛七层',
            fucName: '传送.citymove(D5071,8,10,50000)',
            hint: "5w",
        },
        {
            name: '祖玛七层',
            fucName: '传送.citymove(D5071,8,10,50000)',
            hint: "5w",
        },
        {
            name: '牛魔五层',
            fucName: '传送.citymove(D2076,0,0,50000)',
            hint: "5w",
        },
        {
            name: '霸者大厅',
            fucName: '传送.citymove(D2008,0,0,50000)',
            hint: "5w",
        },
        {
            name: '幻境七层',
            fucName: '传送.citymove(H007,112,19,50000)',
            hint: "5w",
        },
        {
            name: '未知暗殿',
            fucName: '传送.citymove(M001,78,77,50000)',
            hint: "5w",
        },

    ]

    let ItemsString = getShowString(showNameList);
    Npc.Say(Player, ItemsString)

}

export function 元宝传送查看(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    let showNameList = [
        {
            name: '藏宝阁',
            fucName: '传送.元宝传送(H201,119,189,10)',
            hint: "10元宝"
        },
        {
            name: '玛雅',
            fucName: '传送.元宝传送(Fama1,85,86,10)',
            hint: "10元宝"
        },
        {
            name: '魔龙谷',
            fucName: '传送.元宝传送(64,0,0,20)',
            hint: "20元宝"
        },
        {
            name: '奴隶山谷',
            fucName: '传送.元宝传送(L001,16,24,30)',
            hint: "30元宝"
        },
        {
            name: '雷炎神殿',
            fucName: '传送.元宝传送(hl001,0,0,40)',
            hint: "40元宝"
        },
        {
            name: '狐月神殿',
            fucName: '传送.元宝传送(fox01,0,0,60)',
            hint: "60元宝"
        },
    ]

    let ItemsString = getShowString(showNameList);
    Npc.Say(Player, ItemsString)

}



export function citymove(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    if (Player.Gold >= Args.Int[3]) {
        Player.Gold = Player.Gold - Args.Int[3]
        let map = Args.Str[0]
        let x = Args.Int[1] || 0;
        let y = Args.Int[2] || 0;
        if (x > 0 && y > 0) {
            Player.MapMove(map, x, y)
        }
        else {
            Player.RandomMove(map)
        }
    } else {
        Npc.MessageBox(Player, `对不起,你的金币不足${Args.Int[3]},无法传送.`)
    }

}
export function 元宝传送(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    if (Player.GameGold >= Args.Int[3]) {
        Player.GameGold = Player.GameGold - Args.Int[3]
        let map = Args.Str[0]
        let x = Args.Int[1] || 0;
        let y = Args.Int[2] || 0;
        if (x > 0 && y > 0) {
            Player.MapMove(map, x, y)
        }
        else {
            Player.RandomMove(map)
        }
    } else {
        Npc.MessageBox(Player, `对不起,你的元宝不足${Args.Int[3]},无法传送.`)
    }

}

export function showTime(Npc: TNormNpc, Player: TPlayObject, Args: TArgs) {
    let nowdate = new Date();
    let year = nowdate.getFullYear()
    let month = nowdate.getMonth() + 1
    let date = nowdate.getDate()
    let day = nowdate.getDay()
    let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
    let h = nowdate.getHours()
    let m = nowdate.getMinutes()
    let s = nowdate.getSeconds()
    h = checkTime(h)
    m = checkTime(m)
    s = checkTime(s)
    let S = year + "年" + month + "月" + date + "日" + week[day] + " " + h + ":" + m + ":" + s;
    Npc.MessageBox(Player, S)
}

function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}